package com.huiyeji.dynamic.core.bean;

import com.huiyeji.dynamic.core.annotations.DynamicBean;
import com.huiyeji.dynamic.core.annotations.DynamicMethod;

import java.util.*;

@DynamicBean("list")
public class DynamicList {

    @DynamicMethod
    public boolean hasObject(Collection<?> collection){
        return collection != null && collection.size() > 0;
    }

    @DynamicMethod
    public List<?> createList(){
        return new ArrayList<>();
    }

    @DynamicMethod
    public Set<?> createSet(){
        return new HashSet<>();
    }

    @DynamicMethod
    public Object[] toArray(Collection<?> collection){
        return collection.toArray();
    }

    public List<?> of(Object o1){
        List<Object> list = new ArrayList<>();
        list.add(o1);
        return list;
    }

    public List<?> of(Object o1,Object o2){
        List<Object> list = new ArrayList<>();
        list.add(o1);
        list.add(o2);
        return list;
    }

    public List<?> of(Object o1,Object o2,Object o3){
        List<Object> list = new ArrayList<>();
        list.add(o1);
        list.add(o2);
        list.add(o3);
        return list;
    }

    public List<?> of(Object o1,Object o2,Object o3,Object o4){
        List<Object> list = new ArrayList<>();
        list.add(o1);
        list.add(o2);
        list.add(o3);
        list.add(o4);
        return list;
    }

    public List<?> of(Object o1,Object o2,Object o3,Object o4,Object o5){
        List<Object> list = new ArrayList<>();
        list.add(o1);
        list.add(o2);
        list.add(o3);
        list.add(o4);
        list.add(o5);
        return list;
    }

    public List<?> of(Object o1,Object o2,Object o3,Object o4,Object o5,Object o6){
        List<Object> list = new ArrayList<>();
        list.add(o1);
        list.add(o2);
        list.add(o3);
        list.add(o4);
        list.add(o5);
        list.add(o6);
        return list;
    }
}
